package middle;

import java.util.ArrayList;
import java.util.List;

public class Solution_77 {
    private List<List<Integer>> rst;
    public List<List<Integer>> combine(int n, int k) {
        rst = new ArrayList<>();
        dps(n, 1, new ArrayList<>(), k);
        return rst;
    }

    private void dps(int n, int now, List<Integer> list, int k) {
        if (list.size() == k) {
            rst.add(new ArrayList<>(list));
            return;
        }
        ;
        for (int i = now; i <= n - k + list.size() + 1; i++) {
            list.add(i);
            dps(n, i + 1, list, k);
            list.remove(list.size() - 1);
        }
    }

    public static void main(String[] args) {
        Solution_77 model = new Solution_77();
        System.out.println(model.combine(1, 1));
    }
}
